package com.springboot.demo.design.pattern.provider;

import com.springboot.common.entity.request.Parameter;
import com.springboot.common.entity.response.Result;
import com.springboot.db.entity.User;
import com.springboot.demo.design.pattern.form.FormFactory;
import com.springboot.demo.design.pattern.interfaces.UserModifyService;
import com.springboot.demo.design.pattern.palace.PalaceFactory;
import com.springboot.demo.design.pattern.request.user.UserSaveParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用户接口提供类
 *
 * @author supu
 * @date 2019-03-20 9:58
 **/
@Component
public class UserProvider implements UserModifyService {
    @Autowired
    private PalaceFactory palaceFactory;
    @Autowired
    private FormFactory formFactory;

    @Override
    public Result<User> saveUser(Parameter<UserSaveParam> parameter) {
        return palaceFactory.getPalace().submit(formFactory.saveUser(parameter)).getResult();
    }
}
